package com.china08.yxyapi.api.h5.par.study.scoreport.stureport;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.china08.yxyapi.entity.mg.scoreport.report.ExamStuReport;
import com.china08.yxyapi.model.YxyApiRespModel;
import com.china08.yxyapi.repository.mg.scoreport.ExamStuReportRepository;
import com.china08.yxyapi.util.DateUtils;

/**
 * 学生考试报告————查看报告
 * 
 */
@CrossOrigin
@RestController
public class ExamStuReportFindOneController {

    @Autowired
    private ExamStuReportRepository examStuReportRepository;

    @RequestMapping(value = "/api_yw/h5/par/study/scoreport/stureport/getone", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public RespModel process(HttpServletRequest request, HttpServletResponse response, @RequestParam String id) {

    	Assert.notNull(StringUtils.defaultIfBlank(id, null), "学生报告编号不能为空");
        ExamStuReport esr = examStuReportRepository.findOne(id);
        RespModel respModel = new RespModel();
        respModel.id = esr.getId();
        respModel.examId = esr.getExamId();
        respModel.examName = esr.getExamName();
        respModel.type = esr.getType();
        respModel.teaNick = esr.getTeaNick();
        respModel.stuNick = esr.getStuNick();
        respModel.gender = esr.getGender();
        respModel.bookContents = esr.getBookContents();
        respModel.knowRemark = esr.getKnowRemark();
        respModel.examDate = DateUtils.formatDate2(esr.getExamDate());
        respModel.subject = esr.getSubject();
        respModel.stuTotalScore = esr.getStuTotalScore();
        respModel.scoreType = esr.getScoreType();
        respModel.quesTypeRemark = esr.getQuesTypeRemark();
        respModel.classCompareRemark = esr.getClassCompareRemark();
        respModel.classCompareAverageScore = esr.getClassCompareAverageScore();
        respModel.lastExamCompare = esr.getLastExamCompare();
        respModel.lastExamCompareFlag = esr.getLastExamCompareFlag();
        respModel.nextExamScore = esr.getNextExamScore();
        respModel.nextExamRemark = esr.getNextExamRemark();
        return respModel;
    }

    /**
     * 响应参数
     * 
     */
    public static class RespModel extends YxyApiRespModel {
        // 学生报告
        public String id;//
        // 考试ID
        public String examId;
        // 考试名称
        public String examName;
        // 考试类型
        public String type;
        // 教师名称
        public String teaNick;
        // 学生名称
        public String stuNick;
        // 学生性别
        public Integer gender;
        // 章节
        public Integer bookContents;
        // 知识点覆盖
        public Integer knowRemark;
        // 考试时间
        public String examDate;
        // 科目名称
        public String subject;
        // 学生本次考试成绩总分数
        public Double stuTotalScore;
        /**
         * 成绩类型 0--洪荒真学圣,1--知识收割机,2--学习特能王,3--学习小能手,4--秦奋老司机,5--吃瓜学众
         */
        public String scoreType;
        // 题型评语
        public String quesTypeRemark;
        // 班级对比评价
        public String classCompareRemark;
        // 班级平均分
        public double classCompareAverageScore;
        // 上次考试比较
        public String lastExamCompare;
        // 上次考试比较是否显示 0--不显示,1--显示
        public Integer lastExamCompareFlag;
        // 下次成绩预测
        public String nextExamScore;
        // 下次成绩预测评语
        public String nextExamRemark;
    }
}
